home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 4 / Amiga Tools 4.iso / tools / mail-tools / thor / thor_2.22 / thor.lha / rexx / KeepMsg.thor < prev    next >
Text File  |  1995-12-18  |  3KB  |  108 lines

  1. /*
  2. ** $VER: KeepMsg.thor 1.2 (15.5.95) Eirik Synnes
  3. **
  4. ** Copies the current message to a "Keep" conference and sets the KEEP flag
  5. ** Specify the conference name in the toconf string below. If the conference
  6. ** doesn't exist it will be created.
  7. **
  8. ** New in 1.1:
  9. ** o Supports hazelevels
  10. **
  11. ** New in 1.2:
  12. ** o Updates conference window after the deed is done
  13. ** o Uses copyback buffer
  14. **
  15. */
  16.  
  17. options results
  18.  
  19. toconf = 'The Keep'
  20.  
  21. CDF_NOT_ON_BBS   = '00008000'x  /* This conference is not on the bbs. */
  22.  
  23. /* Open Thor and BBSREAD ARexx ports' */
  24.  
  25. p=address()||' '||show('P',,);if pos('THOR.',p)>0 then thorport=word(substr(p,pos('THOR.',p)),1);else do;say 'No THOR port found!';exit(0);end
  26. if ~show('p', 'BBSREAD') then do; address command; "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"; "WaitForPort BBSREAD"; end
  27.  
  28. address(thorport)
  29. trace off; CURRENTMSG curmsg; trace on
  30.  
  31. if rc ~= 0 then do
  32.  REQUESTNOTIFY '"'THOR.LASTERROR'"' '"_Abort"'
  33.  exit(0)
  34.  end
  35.  
  36. address(bbsread)
  37. READBRMESSAGE '"'curmsg.BBSNAME'"' '"'curmsg.CONFNAME'"' '"'curmsg.MSGNR'"' TEXTSTEM text HEADSTEM head DATASTEM data
  38. if rc ~= 0 then do
  39.  address(thorport)
  40.  REQUESTNOTIFY '"'BBSREAD.LASTERROR'"' '"_Abort"'
  41.  exit(0)
  42.  end
  43.  
  44. if head.fromname        ~= "HEAD.FROMNAME"        then text.fromname        = head.fromname
  45. if head.fromaddr        ~= "HEAD.FROMADDR"        then text.fromaddr        = head.fromaddr
  46. if head.toname          ~= "HEAD.TONAME"          then text.toname          = head.toname
  47. if head.toaddr          ~= "HEAD.TOADDR"          then text.toaddr          = head.toaddr
  48. if head.msgid           ~= "HEAD.MSGID"           then text.msgid           = head.msgid
  49. if head.refid           ~= "HEAD.REFID"           then text.refid           = head.refid
  50. if head.creationdate    ~= "HEAD.CREATIONDATE"    then text.creationdate    = head.creationdate
  51. if head.creationdatetxt ~= "HEAD.CREATIONDATETXT" then text.creationdatetxt = head.creationdatetxt
  52. if head.subject         ~= "HEAD.SUBJECT"         then text.subject         = head.subject
  53.  
  54. if text.TEXT.COUNT = 0 then do
  55.  address(thorport)
  56.  REQUESTNOTIFY '"'No message body.'"' '"'_Ok'"'
  57.  exit(0)
  58.  end
  59.  
  60. text.replyconf = curmsg.CONFNAME
  61.  
  62. priv = ""; urg = ""; imp = ""
  63.  
  64. if bittst(data.flags,2) then priv = "PRIVATE"
  65. if bittst(data.flags,11) then urg = "URGENT"
  66. if bittst(data.flags,12) then imp = "IMPORTANT"
  67.  
  68. BUFMODE COPYBACK
  69.  
  70. WRITEBRMESSAGE '"'curmsg.BBSNAME'"' '"'toconf'"' STEM text priv urg imp
  71. if rc ~= 0 then do
  72.  errmsg = BBSREAD.LASTERROR
  73.  if errmsg = 'Unknown conference' then do
  74.   CONFIGCONF '"'curmsg.BBSNAME'"' '"'toconf'"' SET c2x(CDF_NOT_ON_BBS)
  75.   WRITEBRMESSAGE '"'curmsg.BBSNAME'"' '"'toconf'"' STEM text priv
  76.   if rc ~= 0 then do
  77.    address(thorport)
  78.    REQUESTNOTIFY '"Couldn''t write message:\n'errmsg'"' '"_Ok"'
  79.    BUFMODE ENDCOPYBACK
  80.    exit(0)
  81.    end
  82.   end
  83.  else do
  84.   address(thorport)
  85.   REQUESTNOTIFY '"Couldn''t write message:\n'errmsg'"' '"_Ok"'
  86.    BUFMODE ENDCOPYBACK
  87.   exit(0)
  88.   end
  89.  end
  90.  
  91. mnr = result
  92. repl = ""
  93. if bittst(data.flags, 1) then repl = "SETREPLIED"
  94.  
  95. address(bbsread)
  96. UPDATEBRMESSAGE '"'curmsg.BBSNAME'"' '"'toconf'"' mnr SETKEEP repl HAZELEVEL data.HAZELEVEL
  97. if rc ~= 0 then do
  98.  address(thorport)
  99.  REQUESTNOTIFY '"Couldn''t update message:\n'BBSREAD.LASTERROR'"' '"_Ok"'
  100.  end
  101.  
  102. BUFMODE ENDCOPYBACK
  103.  
  104. address(thorport)
  105. UPDATECONFWINDOW
  106.  
  107. exit(0)
  108.